package com.liuc.mybatis;

import java.util.Arrays;
import java.util.List;

class User{
    private int id;

    private String name;

    private int age;

    public User(int id, String name, int age) {
        this.id = id;
        this.name = name;
        this.age = age;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    @Override
    public String toString() {
        return "User{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}
public class StreamDemo {
    public static void main(String[] args) {
        User user = new User(12,"A",24);
        User user1 = new User(13,"B",13);
        User user2 = new User(14,"C",14);
        User user3 = new User(15,"D",27);
        User user4 = new User(16,"E",24);

        List<User> list = Arrays.asList(user,user1,user2,user3,user4);
        list.stream().filter(u ->{return  u.getAge()%2==0;}).filter(u ->{return  u.getAge() >14;}).map( u ->{ return u.getName().toLowerCase();}).
                sorted((u1,u2) ->{
                    return u2.compareTo(u1);
                }).limit(1).forEach(System.out::println);

    }

}
